﻿// <copyright file="Url.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-03-25</date>
// <summary>opensocial.Url wrapper class</summary>

namespace opensocial
{
    using System;
    using System.Windows.Browser;
    using Synergist;

    /// <summary>
    /// opensocial.Url wrapper
    /// </summary>
    public class Url
    {
        /// <summary>
        /// Initializes a new instance of the Url class
        /// </summary>
        /// <param name="scriptObject">the JavaScirpt opensocial.Url object</param>
        public Url(ScriptObject scriptObject)
        {
            if (scriptObject == null)
            {
                return;
            }

            this.Address = scriptObject.GetUriField("opensocial.Url.Field.ADDRESS");
            this.LinkText = scriptObject.getField("opensocial.Url.Field.LINK_TEXT") as string;
            this.UrlType = scriptObject.getField("opensocial.Url.Field.TYPE") as string;
        }

        /// <summary>
        /// Gets or sets the Url address
        /// </summary>
        public Uri Address { get; set; }

        /// <summary>
        /// Gets or sets the link text
        /// </summary>
        public string LinkText { get; set; }

        /// <summary>
        /// Gets or sets the Url Type
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "This is the type from the opensocial.Url class.")]
        public string UrlType { get; set; }

        /// <summary>
        /// Gets the properties for the object
        /// </summary>
        /// <returns>a string listing the non-null properties and their values.</returns>
        public override string ToString()
        {
            return Synergist.Utility.GetProperties(this);
        }
    }
}
